package org.huawei260.OD260;

/**
 * @Auther: qingle
 * @Date: 2024/10/27-23:57
 * @Description:
 * @version: 1.0
 */
import java.util.Scanner;
public class O0048_分糖果 {


//	public class Main0048 {
		public static void main(String[] args) {
			Scanner scanner = new Scanner(System.in);
			long x = scanner.nextLong(); // 使用long类型来读取大数字
			solution(x);
			scanner.close();
		}

		private static void solution(long x) {
			int count = 0;

			for (long i = x; i != 1; ) {
				if (i % 2 == 0) {
					i /= 2;
				} else {
					if (i == 3) {
						count += 2;
						break;
					} else {
						if ((i + 1) / 2 % 2 == 0) i++;
						else i--;
					}
				}
				count++;
			}

			System.out.print(count);
		}
//	}
}
